package net.zwet.clanworks.common;

import net.zwet.clanworks.domain.User;
import org.apache.wicket.Session;
import org.apache.wicket.protocol.http.WebSession;
import org.apache.wicket.request.Request;

import java.util.Locale;

/**
 * Created with IntelliJ IDEA.
 * User: hansz
 * Date: 6/14/13
 * Time: 2:39 PM
 * To change this template use File | Settings | File Templates.
 */
public class ClanworksSession extends WebSession {
    public static ClanworksSession get() {
        return (ClanworksSession) Session.get();
    }

    private User user;

    public ClanworksSession(Request request) {
        super(request);
        setLocale(Locale.ENGLISH);
    }

    public synchronized User getUser() {
        return user;
    }

    public synchronized boolean isAuthenticated() {
        return (user != null);
    }

    public synchronized void setUser(User user) {
        this.user = user;
        dirty();
    }
}
